package com.rc.saas.tenant.base;

import com.rc.saas.tenant.common.constant.ShiroConstants;
import com.rc.saas.tenant.model.tenant.TenantUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;

import java.io.Serializable;

/**
 * Created by sven on 2018-07-27
 */
public abstract class BaseVo implements Serializable {
    private String tenantCode;

    private String tenantOperatorCode;

    public String getTenantCode() {
        return tenantCode;
    }

    public BaseVo() {
        Session session = SecurityUtils.getSubject().getSession();
        TenantUser user = (TenantUser) session.getAttribute(ShiroConstants.SESSION_TENANT_USER_KEY);
        if (user != null) {
            this.tenantCode = user.getTenantCode();
            this.tenantOperatorCode = user.getTenantOperatorCode();
        }
    }

    public void setTenantCode(String tenantCode) {
        this.tenantCode = tenantCode;
    }

    public String getTenantOperatorCode() {
        return tenantOperatorCode;
    }

    public void setTenantOperatorCode(String tenantOperatorCode) {
        this.tenantOperatorCode = tenantOperatorCode;
    }
}
